﻿using ApplicationBase.Core.Attributes;
using IdentityService.Domain.Services;
using MediatR;

namespace IdentityService.Application.Commands
{
    //[CheckPermit(PermitDictionary.PermitAdmin)]
    public record DeletePermitCommand(long Id) : IRequest<DeletePermitResult>;

    public class DeletePermitCommandHandler : IRequestHandler<DeletePermitCommand, DeletePermitResult>
    {
        private readonly IPermitService _permitService;
        public DeletePermitCommandHandler(IPermitService permitService)
            => _permitService = permitService;

        public async Task<DeletePermitResult> Handle(DeletePermitCommand request, CancellationToken cancellationToken)
        {
            return await _permitService.DeleteAsync(request.Id);
        }
    }
}
